package com.a3dweijing.wetouch2.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;


import com.a3dweijing.wetouch2.R;
import com.a3dweijing.wetouch2.Util.ImageLoaderUtil;
import com.a3dweijing.wetouch2.bean.ImageList;

import java.util.List;

/**
 * Created by yxd on 2017/12/28.
 */

public class ImageShowAdapter extends RecyclerView.Adapter<ImageShowAdapter.MyViewHolder>{
    private List<ImageList> imageLists;

    public ImageShowAdapter(List<ImageList> imageLists) {
        this.imageLists = imageLists;
    }

    @Override
    public ImageShowAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_imageshow,parent,false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        ImageLoaderUtil.getLoader().loadImg4(imageLists.get(position).getThree_d_img_url(),holder.pic);
        holder.descibe.setText(imageLists.get(position).getThree_d_title());
    }

    @Override
    public int getItemCount() {

        return imageLists.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        ImageView pic;
        TextView descibe;
        public MyViewHolder(View itemView) {
            super(itemView);
            pic= (ImageView) itemView.findViewById(R.id.imageshow_image);
            descibe= (TextView) itemView.findViewById(R.id.imageshow_decribe);
        }
    }
}
